<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<div class="modal fade" id="ocean-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 1000px; height: auto">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">对应传感器</h4>
            </div>
            <div class="modal-body">
                <div class=" form">
                    <form class="cmxform form-horizontal tasi-form" id="billboard_sensor_from" method="post">
                        <input type="hidden" id="billboard" name="billboard" value="${entity.id}">
                        <div class="form-group">
                            <label for="code" class="control-label col-lg-2">广告牌编号 </label>
                            <div class="col-lg-10">
                                <input class="form-control" id="code" name="code" type="text" readonly value="${entity.code}"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="sensorCode" class="control-label col-lg-2">传感器序号 </label>
                            <div class="col-lg-10">
                                <input class="form-control" id="sensorCode" name="sensorCode" type="text"
                                       placeholder="传感器序号"
                                       required/>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-lg-offset-2 col-lg-10">
                                <button class="btn btn-success" type="button" onclick="sensorPage.save()">Save
                                </button>
                                <button class="btn btn-default" type="button" data-dismiss="modal">Cancel</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="application/javascript">
    var validator = $("#billboard_sensor_from").validate();

    var sensorPage = {
        save: function () {
            var billboard, sensorCode;
            billboard = $('#billboard').val();
            sensorCode = $('#sensorCode').val();
            WaitingDialog.show();
            $.post("resources/billboard/sensor", {
                billboard: billboard,
                sensorCode: sensorCode
            }, function (data) {
                console.log(data);
                WaitingDialog.dismiss();
                $("#ocean-modal").modal('hide');
                load();
            });
        }
    }
</script>
